/*
 * File:   mover1d.h
 * Author: oddi
 *
 * Created on October 3, 2010, 1:31 PM
 */

#ifndef _MOVER1D_H
#define	_MOVER1D_H

#ifndef _GLOBAL_DEFINITIONS_H
#include "global_definitions.h"
#endif
#include "ucgrid1d.h"
#include "ebsources.h"
//#include <curand_kernel.h> won\t work. c++?

#define MAX_BUF_SIZE 256
#define EFIELDDUMPFILEZ "ez"

//this API allows to move only 1d systems
//it is supposed there are only Ex and Bz fields in the system
//z is the only dimension of the system
//particles have vz and v_perp speed
//now it works only with one sort of particles


#ifdef	__cplusplus
extern "C" {
#endif

    typedef struct struct_mover1d_parameters {
        ucgrid1d* grid;
        particles_set* set;
        floatdig dt;
    } mover1d_parameters;

    typedef struct struct_mover1d_initialized {
        floatdig* E;
        floatdig* B;
        floatdig* zpool;
        floatdig* vxpool;
        floatdig* vypool;
		floatdig* vzpool;
        floatdig* mvxpool;
        floatdig* mvypool;

        int* flags;
        int cycles;
        floatdig qm;
        floatdig qmc;
        floatdig dt;
        floatdig dx;
    } mover1d;

    typedef mover1d* pmover;

    __host__ mover1d* mover1d_setup_mover();
    __host__ void mover1d_advance(mover1d* mover, particles_set* set, timevar dt);
	__host__ void mover1d_backtracing(mover1d* mover,  particles_set* set, timevar dt);
    __host__ void mover1d_clear_mover(mover1d* mover);
	__host__ void mover1d_postprocessing(mover1d* mover, particles_set* set, floatdig minz, floatdig maxz, floatdig sigma);
	__host__ void mover1d_dump_E_field_into_file(mover1d* mover, char* path, int fid, floatdig minz, floatdig maxz, floatdig dz, floatdig t);

    #ifdef DEBUG
    __host__ void mover1d_make_snapshot_of_ext_E(ucgrid1d*, mover1d*, char*);
    #endif

#ifdef	__cplusplus
}
#endif

#endif	/* _MOVER1D_H */

